<template>
  <div class="content">
    <div class="home_top">
      <img :src="base.top_pic ? base.top_pic : imgurl" alt="">
      <div class="rule_boxs">
         <div class="rule_top">
        <div class="cirbox">
          <div class="c_one"></div>
          <div class="c_two"></div>
          <div class="c_three"></div>
        </div>
        <div class="active" :style="{'color': base.title_color}">输入口令参与活动</div>
        <div class="cirbox">
          <div class="c_three"></div>
          <div class="c_two"></div>
          <div class="c_one"></div>
        </div>
      </div>
      <div class="top_box">
        <van-field class="iptsty" v-model="str" placeholder="输入口令" />
        <!-- <input class="iptsty" type="text" v-model="str" placeholder="输入口令"> -->
        <div class="sure" :style="{'background': base.button_color}" @click="surebtn">确定</div>
      </div>
      </div>
    </div>
    <div class="home_bot">
      <!-- 样式一 -->
      <div class="sty" v-for="(item, index) in datalist" :key="index">
        <div class="h_title">{{item.name}}</div>
        <div v-show="item.show_type === 2" class="home_two">
          <div v-for="(citem, cidx) in item.children" :key="cidx" class="twobox" @click="goto(citem)">
            <img :src="citem.pic" alt="">
          </div>
        </div>
        <div v-show="item.show_type === 1" class="home_one" v-for="(sitem, sidx) in item.children" :key="sidx" @click="goto(sitem)">
          <img :src="sitem.pic" alt="">
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getlist, searcht } from '@/api/public'
export default {
  name: 'Home',
  data () {
    return {
      str: '',
      show: false,
      base: {},
      datalist: [],
      imgurl: require('../../assets/bg.png')
    }
  },
  created () {
    this.getdata()
  },
  methods: {
    getdata () {
      getlist().then(res => {
        const { base, data } = res || {}
        if (base) {
          this.base = base
        }
        this.datalist = data
      }).finally(() => {
      })
    },
    surebtn () {
      const { str } = this
      searcht(str).then(res => {
        this.str = ''
        // this.$toast.success('核销成功')
      }).finally(() => {
      })
    },
    goto ({ url }) {
      window.location.href = url
    }
  }
}
</script>

<style scoped lang="less">
.content{
  width: 100%;
  height: 100vh;
  background:  #f5f5f5;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  .home_top{
    width: 100%;
    min-height: 327px;
    text-align: center;
    position: relative;
    // z-index: 1;
    img{
      width: 100%;
      background-size: cover;
      font-size: 0;
    }
    .rule_boxs{
      width: 100%;
      position: absolute;
      top: 0;
      left: 0;
      .rule_top{
      margin: 70px auto 50px;
      display: flex;
      align-items: center;
      justify-content: center;
      .active{
        margin: 0 20px;
        font-size: 32px;
        line-height: 29px;
        color: #ffffff;
      }
      .cirbox{
        width: 56px;
        height: 16px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        .c_one{
          width: 8px;
          height: 8px;
          border-radius: 4px;
          background-color: #ffffff;
          opacity: 0.7;
        }
        .c_two{
          width: 12px;
          height: 12px;
          border-radius: 6px;
          background-color: #ffffff;
          opacity: 0.7;
        }
        .c_three{
          width: 16px;
          height: 16px;
          border-radius: 10px;
          background-color: #ffffff;
          opacity: 0.7;
        }
      }
    }
    .top_box{
      margin: 0 auto;
      width: 600px;
      height: 88px;
      background-color: #ffffff;
      box-shadow: 0px 10px 30px 0px rgba(51, 51, 51, 0.1);
      border-radius: 44px;
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .iptsty{
        width: 470px;
        outline: none;
        font-size: 28px;
        padding-left: 20px;
        box-sizing: border-box;
      }
      .sure{
        width: 120px;
        height: 88px;
        line-height: 88px;
        font-size: 28px;
        text-align: center;
        color: #333333;
        background-color: #ffd664;
      }
    }
    }
  }
  .home_bot{
    margin-top: 20px;
    padding: 0 20px;
    box-sizing: border-box;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    &::-webkit-scrollbar {
      width: 0;
      height: 0;
    }
    .sty{
      margin-bottom: 20px;
      width: 100%;
      padding: 20px;
      background: white;
      border-radius: 20px;
      box-sizing: border-box;
      .h_title{
        font-size: 28px;
        color: #222222;
      }
      .home_two{
        margin-top: 20px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        .twobox{
          width: 325px;
          height: 175px;
          border-radius: 10px;
          overflow: hidden;
          img{
            width: 100%;
            height: 100%;
            background-size: cover;
            object-fit: cover;
          }
        }
      }
      .home_one{
        margin-top: 20px;
        width: 100%;
        height: 175px;
        border-radius: 10px;
        overflow: hidden;
        img{
          width: 100%;
          height: 100%;
          background-size: cover;
          object-fit: cover;
        }
      }
    }
  }
}
</style>
